package stardust.product.utils.transmit.auto;

import java.io.IOException;
import java.util.Properties;

public class Authenticator
{
  
  private static Properties CONFIG = new Properties();
  
  public static void loadConfig()
  {
    Authenticator.CONFIG.clear();
    
    try
    {
      Authenticator.CONFIG.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("auth.properties"));
    }
    catch (IOException e)
    {
      e.printStackTrace();
    }
  }
  
  public static boolean isAuthenticateEnabled()
  {
    Authenticator.loadConfig();
    
    return Authenticator.CONFIG.getProperty("http.authenticate") == null || !Authenticator.CONFIG.getProperty("http.authenticate").equalsIgnoreCase("BASIC") ? false : true;
  }

  public static String getRealm()
  {
    Authenticator.loadConfig();
    
    return Authenticator.CONFIG.getProperty("http.realm");
  }
  
  public static String getUsername()
  {
    Authenticator.loadConfig();
    
    return Authenticator.CONFIG.getProperty("http.username");
  }
  
  public static String getPassword()
  {
    Authenticator.loadConfig();
    
    return Authenticator.CONFIG.getProperty("http.password");
  }
  
}
